<template>
  <el-card class="tree-card">
    <!-- {{ depts }} -->
    <!-- 用了一个行列布局 -->
    <el-row type="flex" justify="space-between" align="middle" style="height: 40px">
      <el-col :span="20">
        <span>{{ companyName }}</span>
      </el-col>
      <el-col :span="4">
        <el-row type="flex">
          <!-- 两个内容 -->
          <el-col :span="12">负责人</el-col>
          <el-col :span="12">
            <!-- 下拉菜单 element -->
            <el-dropdown>
              <span>
                操作<i class="el-icon-arrow-down" />
              </span>
              <!-- 下拉菜单 -->
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="addDpt">添加子部门</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <MyTree :depts="depts" :show-form="showForm" @closeForm="showForm=false" />
  </el-card>
</template>

<script>
import { mapGetters } from 'vuex'
import MyTree from './components/myTree.vue'
export default {
  name: 'Department',
  components: {
    MyTree

  },
  data() {
    return {
      showForm: false
    }
  },
  computed: {
    ...mapGetters('departments', ['depts', 'companyName'])
  },
  created() {
    this.$store.dispatch('departments/getDepartmentData')
  },
  methods: {
    addDpt() {
      this.showForm = true
    }
  }
}
</script>

<style scoped>
.tree-card {
  padding: 30px 30px;
  font-size:14px;
}
</style>
